package com.yunao.web.controller;

import com.yunao.commons.Exception.YunaoException;
import com.yunao.commons.enums.ResultEnum;
import com.yunao.commons.enums.SearchTypeEnum;
import com.yunao.commons.form.MtForm;
import com.yunao.commons.metasearch.bean.PageBean;
import com.yunao.commons.metasearch.bean.PageUtil;
import com.yunao.commons.metasearch.common.Convert;
import com.yunao.commons.metasearch.entity.CatchResult;
import com.yunao.commons.metasearch.ms.MsSystem;
import com.yunao.commons.utils.ResultVOUtil;
import com.yunao.commons.vo.ResultVO;
import com.yunao.commons.metasearch.entity.CatchResults;
import com.yunao.web.annotation.UserLoginToken;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.NumberFormat;
import java.util.HashMap;
import java.util.Map;

/**
 * 元搜索
 *
 *
 * @author wyc
 *
 */
@RestController
@Scope("prototype")
@RequestMapping("/ms")
public class MetasearchController {

    private static final long serialVersionUID = 1L;

//    public static void main(String[] args) {
//        String type = null;
//        String sort = null;
//        String kw= null;
//        String source= null;
//        String range= null;
//        String begin= null;
//        String end= null;
//        String dup= null;
//        int page= 0;
//        String media  = null;
//        if (type == null || type.length() == 0)
//            type = SearchTypeEnum.MS_WEIBO.getSearchType();
//
//        if (kw == null || kw.length() == 0) {
//            kw = "北京市";
//        }
////        /*
////         * 元搜索
////         */
//        // 元搜索查询条件
//        if(dup==null)
//            dup="fq";
//        if(sort==null)
//            sort="t";
//        if(range==null)
//            range="d";
//            /*if(range==null && begin==null && end==null)
//                range="d";*/
//        MtForm mt = new MtForm(kw, type, source, sort, range, begin, end, dup, page,media);
////            MtForm mt = new MtForm();
////            mt.setType(type);
////            mt.setWord(kw);
//        long t = System.currentTimeMillis();
//        // 元搜索检索
//        try {
////            MsSystem.init();
//            CatchResults rsts = MsSystem.getInstance().query(mt);
//            rsts.stream().forEach(
//                    e -> System.out.println(e)
//            );
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }

    /**
     * showdoc
     * @catalog API文档/全网搜索
     * @title 全网搜索
     * @description 根据表单内容进行全网搜索
     * @method post
     * @url /metasearch/ms/search
     * @param type 可选 string 搜索类型,news,webpage,weibo,tieba,wenda,weixin,forum
     * @param sort 可选 string 排序规则，t(时间排序),d(相关度排序)
     * @param kw 必选 string 关键词
     * @param source 可选 string 资源网站
     * @param range 可选 string 时间段，d(day),w(week),m(month)
     * @param begin 可选 string 自定义开始时间
     * @param end 可选 string 自定义结束时间
     * @param page 可选 string 页数
     * @param pageSize 可选 string 页大小
     * @return {"code": 0,"msg": "成功","data": {"allPages": 98300,"rsts": [{"id": 0,"name": "baidu","title": "<em>北京</em>迎大雨 民众冒雨出行","summary": "<em>北京市</em>气象台2019年9月9日18时15分发布暴雨蓝色预警信号:预计,当前至10日5时,\n<em>北京市</em>局地将出现小时雨强达30mm左右的短时强降水,山区及浅山区出现强降水诱发的... \n","href": "http://news.163.com/photoview/00AP0001/2303995.html","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece763104a8023584380143fd3d1027fa3c215cc79191b1a20beff7c755519d1c70f0503ad4b5ff7f0377036082bb08cc8ff109be4cc3c6ad567627f0bf64205a31ab8bb3132b22b&p=882a964492b112a05aaf886f5c4f&newp=882a9644c5b112a05abccf12475592695c02dc3051d4d501298ffe0cc4241a1a1a3aecbb24241502d9c478610abb0f31aba7747d605f76a4e9&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=10","info": "网易 2019年09月09日 19:58","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "<em>北京市</em>2019年09月10日00时15分解除大风蓝色预警信号","summary": "千龙网\n<em>北京</em>9月10日讯?\n<em>北京市</em>突发事件预警信息发布中心10日通过千龙网发布:目前,\n<em>北京市</em>大部分地区风力已减弱,市气象台2019年9月10日00时15分解除大风蓝色预警信号... \n","href": "http://news.163.com/19/0910/00/EOM3PUGQ000189FH.html","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece763104a8023584380143fd3d1027fa3c215cc79584a5a64e8b8253f1206ceb2011800cd2e2989f2347034092bc3e1df883d87fdcd763bcd7a742613913111c469acdc3652d6539b&p=c470d116d9c103ea1fbd9b7558&newp=8b2a970a8a8114ff57e6cb3c5553d8265f15ed673bc3864e1290c408d23f061d4866e0bf2d241703d0c1777347c2080ba8ff612e614c7cf5ce&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=9","info": "网易 2019年09月10日 01:01","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "中国平安推十项服务首都举措 “金融+科技+医疗”推动综合协同","summary": "<em>北京</em>作为全国的“四个中心”,在当前京津冀一体化、区域协同迈向高质量发展的转型升级关键时期,尤需服务保障。 近日,中国平安整合\n<em>北京</em>地区资源,升级并推出支持首都经济... \n","href": "https://finance.sina.com.cn/stock/relnews/cn/2019-09-10/doc-iicezzrq4921379.shtml","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed19fa950d100b833d4507dc326bc0d0623e8fcf1b84642c101a39f4bb50734c199283213658b2090bb4ac6137761e71eb86c88a49d6ac925e2d833034061f845c448e48b8cb307e9a71c712a1ef5ae1b1f03192abd9c4df231290155a2494b5d61a561bdd1ff30341e0b1e93f022c1b&p=8c64cf1d86cc42a805b3c7710f0e&newp=9867df1286cc42a842b8c7710f4492695c02dc3051d7d101298ffe0cc4241a1a1a3aecbb24241502d9c478610abb0f31aba7747d605f76adce&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=8","info": "新浪 2019年09月10日 19:05","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "将于10月份上市 <em>北京</em>汽车EU7正式下线","summary": "作为\n<em>北京</em>汽车的一款全新中型纯电动轿车,EU7在外观设计方面让人眼前一亮,不俗的颜值具有很强的辨识度,内饰部分也做到了中级车应有的豪华档次感。我们能在EU7身上看... \n","href": "http://auto.163.com/19/0909/15/EOL4856R0008856R.html","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece76310459020444380143fd3d1027fa3c215cc79584a5a64e8b92c3f1303ceb2011907a54e588af234703d0927b3fbdf883d87fdcd763bcd7a742613913111c469acdc3652d6539b&p=cb39c64ad4871cf040bd9b7858&newp=84759a43969c57fc57ef8c216153d8265f15ed673ec3864e1290c408d23f061d4866e0bf2d241703d0c1777347c2080ba8ff612e61437fa1&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=7","info": "网易汽车 2019年09月09日 15:47","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "<em>北京</em>全路网交通指数为8.0 建议选择公共交通出行","summary": "#路况播报# 目前,全路网的交通指数为8.0,属于严重拥堵级别,请您尽量选择公共交通出行。 作者最新文章 太狠心!双胞胎也遗弃!出生才5天啊!被发现时大宝已死亡!... \n","href": "http://baijiahao.baidu.com/s?id=1644283265065951701&wfr=spider&for=pc","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9d78d513d9d431ac4f9d97697d61c0151240c72362d88a5339968449e0794611143dbbe074784359c4c50b3752f41f1bfdf041236a5c3df68cc9fc118bac935e2c8c21327016874116d41babcc4d22c2259259feaf1da2eeb02592d893918402048a44057ed4adcb4d0162883e&p=882a94438e831bfc57ef8e3b5956&newp=993bcf0f86cc40a901bcc7710f5092695912c10e3cd7c44324b9d71fd325001c1b69e3b823281603d4c6786c15e9241dbdb239256b5579e6&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=6","info": "环球网 2019年09月10日 18:15","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "<em>北京</em>文化","summary": "新浪财经为您提供\n<em>北京</em>文化(000802)股票实时行情走势,实时资金流向,实时新闻资讯,研究报告,股吧互动,交易信息,个股点评,公告,财务指标分析等与\n<em>北京</em>文化(000802)股票... \n","href": "https://finance.sina.com.cn/realstock/company/sz000802/nc.shtml","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed19fa950d100b833d4507dc326bc0d0623e8fcf1b84642c101a39f4bb50734c1993922f3940e9140db3ed672f684173ebd0d5c902dfb990222d883a68210b863653895ff09552609c60c655fedf1af0caf325e3d9c5a0d4&p=8239c54ad6c340e805addb2d0214c6&newp=81759a45d6c207b92abe9b7c564280231610db2151d6d4126b82c825d7331b001c3bbfb423271105d3c678620aae4259effb3076350923a3dda5c91d9fb4c57479ce3146&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=5","info": "新浪 1998年01月08日 00:00","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "<em>北京</em>城建","summary": "新浪财经为您提供\n<em>北京</em>城建(600266)股票实时行情走势,实时资金流向,实时新闻资讯,研究报告,股吧互动,交易信息,个股点评,公告,财务指标分析等与\n<em>北京</em>城建(600266)股票... \n","href": "https://finance.sina.com.cn/realstock/company/sh600266/nc.shtml","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed19fa950d100b833d4507dc326bc0d0623e8fcf1b84642c101a39f4bb50734c1993922f3940e9140db3ed672f684173ebd0d5c910d9b990282b8c3a68210b863653895ff09552609c60c655fedf1af0caf325e3d9c5a0d4&p=882a9546d68733fc57efd6621c478e&newp=882a9546d6d033fc57efc525615c94231610db2151d7c44324b9d71fd325001c1b69e7be26231007d7c077660aaa4c57ecf43478341766dada9fca458ae7c43b5d&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=4","info": "新浪 2007年02月12日 11:25","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "<em>北京</em>银行","summary": "新浪财经为您提供\n<em>北京</em>银行(601169)股票实时行情走势,实时资金流向,实时新闻资讯,研究报告,股吧互动,交易信息,个股点评,公告,财务指标分析等与\n<em>北京</em>银行(601169)股票... \n","href": "https://finance.sina.com.cn/realstock/company/sh601169/nc.shtml","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed19fa950d100b833d4507dc326bc0d0623e8fcf1b84642c101a39f4bb50734c1993922f3940e9140db3ed672f684173ebd0d5c910d9b9912b2b833a68210b863653895ff09552609c60c655fedf1af0caf325e3d9c5a0d4&p=c470d116d9c103ea1fbd9b7e0d1482&newp=8b2a970a8a8114ff57ed947c52548f231610db2151d6d2176b82c825d7331b001c3bbfb423271105d3c678620aae4259effb3076350923a3dda5c91d9fb4c57479c77b7625&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=3","info": "新浪 2007年09月05日 08:00","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "首都之窗_<em>北京市</em>人民政府门户网站","summary": "首都之窗是\n<em>北京市</em>国家机关在互联网上统一建立的网站群,包括\n<em>北京市</em>人民政府门户网站、市级各部门、各区政府和各级国家机关网站。首都之窗网站由\n<em>北京市</em>人民政府办公厅主办... \n","href": "http://www.beijing.gov.cn/default.htm","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece763105392230e54f7336b8c884e23818448e4310605506694ea7b3f465387963b3947b8492bb0b66966725e60e194dff849cacb913f5fff30477b&p=8c64cf1d86cc47af05b3c7710f0e&newp=9867df1286cc47af42b8c7710f4492695d0fc20e38d3d201298ffe0cc4241a1a1a3aecbf22231104d0c1796c00a44c59e1f632703d0034f1f689df08d2ecce7e35dd&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=2","info": "首都之窗 2016年09月28日 20:25","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null},{"id": 0,"name": "baidu","title": "<em>北京</em>天气预报,<em>北京</em>7天天气预报,<em>北京</em>15天天气预报,<em>北京</em>天气查询 - ...","summary": "全国&gt; \n<em>北京</em> &gt; 城区 18:00更新 | 数据来源 中央气象台今天 7天 8-15天 40天 雷达图 8日(今天) 多云 22℃ &lt;3级 9日(明天) 小雨 32℃/21℃ &lt;3级 ... \n","href": "http://www.weather.com.cn/weather/101010100.shtml","source": "","pubdate": "1970年1月1日 08:00","q": 0,"author": "","avatar": null,"links": "http://cache.baidu.com/c?m=9d78d513d9d431ac4f9d97697d61c0151240c72362d88a5339968449e07946040223f4bb50674757959f2b2716af3e0db7af217240527caade9fdb0c87ecd2352c8a2436731e854310c419d88a1c639e7e&p=882a9546dc9b01f50be29664484297&newp=993bcf0f86cc41ac52b4c52d021491231610db2151d7d3156b82c825d7331b001c3bbfb423271105d3c678620aae4259effb3076350923a3dda5c91d9fb4c57479d176&user=baidu&fm=sc&query=%B1%B1%BE%A9&qid=89150158001f3b3e&p1=1","info": "中国天气网 2017年01月26日 23:08","media": null,"img": "","imgs": [],"vdpic": null,"video": null,"more": "","expand": null,"reply": "","repeat": "","view": null,"rer": null}],"search_results": "<label style=\"margin-top:8px;font-size: 12px;line-height: 28px;color: #989898;width: auto;height: 26px;\"> 已为您找到983,000条结果，用时 38.81秒</label>","pageBean": {"totalItems": 983000,"totalPage": 98300,"currentPage": 1,"pageSize": 10,"startPageIndex": 1,"endPageIndex": 10}}}
     * @remark 传入参数的时候，source根据选择的类型有不同网站，news:baidu,qihu,sogou,chinaso；weixin:soso；webpage:baidu,sogou,qihu,chinaso,bing；weibo:sina；tieba:baidu；forum:tianya；wenda:baidu,qihu,sogou
     * @number 01
     */
    @UserLoginToken
    @RequestMapping(value = "/search",method = RequestMethod.POST)
    public ResultVO search(
            String type,
            String sort,
            @RequestParam(name = "kw",required = true) String kw,
            String source,
            String range,
            String begin,
            String end,
            String dup,
            String page,
            String media,
            String pageSize
    ) {

        Map<String,Object> data = new HashMap<>();
        try {
            // 普通搜索默认网页搜索
            if(type == null || type.length() == 0)
                type = SearchTypeEnum.MS_WEBPAGE.getSearchType();

            if (kw == null || kw.length() == 0) {
                throw new YunaoException(ResultEnum.PARAM_ERROR);//关键词为空
            }
            /*
             * 元搜索
             */
            // 元搜索查询条件
            if(dup==null)
                dup="fq";

            if(sort==null)
                sort="t";
            if(range==null)
                range="d";
            /*if(range==null && begin==null && end==null)
                range="d";*/
            int p = Convert.getInt(page);
            int s = Convert.getInt(pageSize);
            MtForm mt = new MtForm(kw, type, source, sort, range, begin, end, dup, p,media,s);
//            MtForm mt = new MtForm();
            long t = System.currentTimeMillis();
            // 元搜索检索
            CatchResults rsts = MsSystem.getInstance().query(mt);
            if(rsts!=null){
                if(type.equals("weibo")){
                    rsts.sort();
                }

                if(type.equals("webpage")||type.equals("news")||type.equals("forum")||type.equals("wenda")){
                    rsts.sort();
                }

                for(int i=0;i<rsts.size();i++){
                    CatchResult rst=rsts.get(i);
                    if(!type.equals("weibo")){
                        if(rst.getHref().equals("")||rst.getTitle().equals("")){
                            rsts.remove(i);
                            i--;
                        }
                    }
                }
            }

            t = System.currentTimeMillis() - t;
            if (rsts != null && rsts.size() > 0) {
                data.put("rsts", rsts);
                // 分页
                PageBean pageBean = PageUtil.query(rsts.getTotal(), p,s);
                data.put("pageBean",pageBean);
                data.put("allPages", pageBean.getTotalPage());
                // search results
                data.put("search_results",this.results(rsts.getTotal(), t));
            } else {
                data.put("rsts", rsts);
                // 分页
                PageBean pageBean = PageUtil.query(rsts.getTotal(), p,s);
                data.put("pageBean",pageBean);
                data.put("allPages",pageBean.getTotalPage());
                data.put("search_results",this.results(0, t));
            }
           return ResultVOUtil.success(data);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return ResultVOUtil.error(ResultEnum.PARAM_ERROR);
    }

    /**
     * 更多专题
     */
//    @RequestMapping("preSubject")
//    public ResponseObject preSubject(
//            String sid,
//            String type
//    ){
//        int id = 0;
//        Map<String,Object> data = new HashMap<>();
//        ResponseObject ro = null;
//        try {
//            id = Convert.getInt(sid);
//            data.put("sId", id);
//            data.put("sType", type);
//            ro = new ResponseObject(1,"成功",data);
//        } catch (Exception e) {
//            ro = new ResponseObject(0,"失败",null);
//            e.printStackTrace();
//        } finally {
//            return ro;
//        }
//    }


    /**
     * 高级搜索
     */
//    @RequestMapping("avd")
//    public ResponseObject avd(
//            String type,
//            String sort,
//            String radio,
//            String query,
//            String range,
//            String dup,
//            String media
//    ) {
//        ResponseObject ro = null;
//        try {
//            if (TYPE_ISEARCH.equals(type)) {
//                this.parse(query);
//                radio = (radio == null || radio.length() == 0) ? "fixed" : radio;
//                if (radio == null || radio.length() == 0 || radio.equals("fixed")) {
//                    radio = "fixed";
//                    range = (range == null || range.length() == 0) ? "7" : range;
//                    SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtil.TIME_FORMAT);
//                    String begin = dateFormat.format(new Date(System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000l));
//                    String end = dateFormat.format(new Date());
//                }
//                sort = (sort == null || sort.length() == 0) ? "date" : sort;
//                dup = (dup == null || dup.length() == 0) ? "fq" : dup;
//            } else if (TYPE_WEIBO.equals(type)) {
//                dup = (dup == null || dup.length() == 0) ? "fq" : dup;
//                sort = (sort == null || sort.length() == 0) ? "t" : sort;
//                media = (media == null || media.length() == 0) ? "0" : media;
//
//            } else {
//                range = (range == null || range.length() == 0) ? "all" : range;
//                sort = (sort == null || sort.length() == 0) ? "t" : sort;
//            }
//            ro = new ResponseObject(1,"成功","avd_"+type);
//        } catch (Exception e) {
//            e.printStackTrace();
//            ro = new ResponseObject(0,"失败",null);
//        } finally {
//            return ro;
//        }
//    }

    /**
     * 检索结果
     *
     * @param total
     *            检索总量
     * @param t
     *            检索时间
     * @return
     */
    private String results(int total, long t) {
        //System.out.println("total:"+total);
        if (total == 0) {
            return "<label style=\"margin-top:8px;font-size: 12px;line-height: 28px;color: #989898;width: auto;height: 26px;\"> 抱歉，没有找到相关的数据</label>";
        } else if(total!=1989) {
            NumberFormat format = NumberFormat.getInstance();
            return "<label style=\"margin-top:8px;font-size: 12px;line-height: 28px;color: #989898;width: auto;height: 26px;\"> 已为您找到"
                    + format.format(total)
                    + "条结果，用时 "
                    + (t / 1000.) + "秒</label>";
        }
        else
            return "";
    }
//    public ResponseObject prepare(
//            int id
//    ){
//        Map<String,Object> session = null;
//        Map<String,Object> data = new HashMap<>();
//        ResponseObject ro = null;
//        try {
//            User user = (User)session.get("user");
//            Organization organ = user.getOrgan();
//            String priHql = "FROM Subject WHERE user = ? AND shared = ? ";
//            String shareHql = "FROM Subject WHERE organ = ? AND shared = ? ";
//            List<Subject> subjects = subjectService.query(priHql, user,2);
//            List<Subject> shareSubs = subjectService.query(shareHql, organ,1);
//            data.put("priSubNum", subjects.size());
//            if (!shareSubs.isEmpty())
//                for (Subject s : shareSubs){
//                    subjects.add(s);
//                }
//            data.put("subjects", subjects);
//            List<Subject> topTitle = new ArrayList<Subject>();
//            topTitle.addAll(subjects.subList(0, subjects.size() > 7 ? 7 : subjects.size()));
//            data.put("subjects2",topTitle);
//
//            data.put("subject_id",id);
//            ro = new ResponseObject(1,"成功",data);
//        } catch (Exception e) {
//            e.printStackTrace();
//            ro = new ResponseObject(0,"失败",null);
//        } finally {
//            return ro;
//        }
//    }
    public static void main(String[] args) {
        String str = "filters=ex1%3a\"ez1\",filters=ex1%3a\"ez2\",filters=ex1%3a\"ez3\"";
        String[] split = str.split(",");
        for(int i=0;i<split.length;i++){
            System.out.println(split[i]);
        }
    }

    private static final String TYPE_ISEARCH = "isearch";
    private static final String TYPE_WEIBO = "weibo";


    private String[] MD;
    private String[] EM;
    private String[] DL;
    private String[] AT;
    private String[] MT;

    public String[] getMD() {
        return MD;
    }

    public void setMD(String[] mD) {
        MD = mD;
    }

    public String[] getEM() {
        return EM;
    }

    public void setEM(String[] eM) {
        EM = eM;
    }

    public String[] getDL() {
        return DL;
    }

    public void setDL(String[] dL) {
        DL = dL;
    }

    public String[] getAT() {
        return AT;
    }

    public void setAT(String[] aT) {
        AT = aT;
    }

    public String[] getMT() {
        return MT;
    }

    public void setMT(String[] mT) {
        MT = mT;
    }


}

